<template>
  <a-carousel arrows>
    <template #prevArrow>
      <div class="custom-slick-arrow" style="left: 10px; z-index: 1">
        <left-circle-outlined />
      </div>
    </template>
    <template #nextArrow>
      <div class="custom-slick-arrow" style="right: 10px">
        <right-circle-outlined />
      </div>
    </template>
    <div v-for="(bd, index) in bannerData" :key="index">
      <img :src="bd.imageUrl" />
    </div>
  </a-carousel>
</template>

<script lang="ts">
import { defineComponent, onMounted, ref } from "vue";
export default defineComponent({
  name: "Banner",
});
</script>
<script lang="ts" setup>
import { LeftCircleOutlined, RightCircleOutlined } from "@ant-design/icons-vue";
import { getBannerApi } from "@/api/home.ts";
import { BannerListType } from "./type.ts";

// Banner 数据
const bannerData = ref<BannerListType>([]);

// 获取 Banner 信息的函数
const getBannerFunc = async () => {
  await getBannerApi().then((res) => {
    bannerData.value = res.banners;
  });
};

// 初始化
onMounted(() => {
  getBannerFunc();
});
</script>

<style lang="scss" scoped>
/* For demo */
:deep(.slick-slide) {
  cursor: pointer;
  text-align: center;
  height: 400px;
  line-height: 400px;
  background: #364d79;
  overflow: hidden;
}

:deep(.slick-arrow.custom-slick-arrow) {
  width: 25px;
  height: 25px;
  font-size: 25px;
  color: #fff;
  background-color: rgba(31, 45, 61, 0.11);
  transition: ease all 0.3s;
  opacity: 0.3;
  z-index: 1;
}
:deep(.slick-arrow.custom-slick-arrow:before) {
  display: none;
}
:deep(.slick-arrow.custom-slick-arrow:hover) {
  color: #fff;
  opacity: 0.5;
}

:deep(.slick-slide h3) {
  color: #fff;
}
</style>
